package com.solarroast.mirrorarray.gui.listeners;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.security.GuardedObject;

import com.solarroast.mirrorarray.SolarRoastConstants;
import com.solarroast.mirrorarray.components.MirrorArray;
import com.solarroast.mirrorarray.components.MirrorArrayItem;
import com.solarroast.mirrorarray.gui.MAIPopup;
import com.solarroast.mirrorarray.gui.MirrorArrayItemWindow;

public class MAIClickListener implements MouseListener, SolarRoastConstants {
	private MAIPopup maiPopup;
	private MirrorArrayItem mAItem;
	private MirrorArray mArray;
	
	public MAIClickListener(MirrorArrayItem mAItem, MirrorArray mArray) {
		this.mArray = mArray;
		this.mAItem = mAItem;
	}
	
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		if(e.isPopupTrigger()) {
			maiPopup = new MAIPopup(mAItem, mArray);
			maiPopup.show(e.getComponent(), e.getX(), e.getY());
		}
		else {
			// left-click
			if(e.isControlDown()) {
				// OS X right-click key
				maiPopup = new MAIPopup(mAItem, mArray);
				maiPopup.show(e.getComponent(), e.getX(), e.getY());
			} 
			else {
				mAItem.printMirrorArrayStatus();
				mAItem.toggleActive();
			}
		}
	}
	
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
	}
	
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub		
	}
	
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
	}
	
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
}
